#!/usr/bin/env python3

def strCommon(s1, s2, start=2):
    minlen = len(s1) if len(s1) > len(s2) else len(s2)
    start = 2 if start <= 2 else start

    for i in range(start, minlen + 1):
        if s1[:i] != s2[:i]:
            return s1[:i - 1]

    return s1[:minlen]

def main():
    s1 = "helloworld"
    s2 = "kyohellohelloworld"
    commStr = ""

    for i, c in enumerate(s1):
        dstStr = s2
        while c in dstStr:
            index = dstStr.index(c)
            tmpComm = strCommon(s1[i:], dstStr[index:], len(commStr))
            if len(tmpComm) > len(commStr):
                commStr = tmpComm
            dstStr = dstStr[index + 1:]

    commStr = "" if len(commStr) < 2 else commStr
    print(commStr)


if __name__ == "__main__":
    main()
